﻿
Partial Class Reportes_ReporteExcel
    Inherits System.Web.UI.Page
    Dim util As New utileria
    Dim sSQL, campos As String
    Protected Sub Reportes_ReporteExcel_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim swhere As String
        campos = Request.QueryString("campos")
        swhere = Util.sWhereFiltro(Session("filtro"))
        sSQL = "Select " + campos + " from animal " + swhere
        Try
            Dim sdsAnimales As New SqlDataSource
            ' Dim sConectionString As String
            ' sConectionString = ConfigurationManager.ConnectionStrings.Item("GanaderiaConnectionString").ToString
            sdsAnimales.ConnectionString = ConfigurationManager.ConnectionStrings.Item("GanaderiaConnectionString").ToString
            sdsAnimales.SelectCommand = sSQL
            sdsAnimales.DataBind()
            Reporte.DataSource = sdsAnimales
            Reporte.DataBind()
            Response.Clear()
            Response.Charset = "UTF-8"
            Response.ContentType = "application/vnd.ms-excel"
            Response.AddHeader("Content-Disposition", "attachment;filename=excelfile.xls")
        Catch ex As Exception
            'lblException.Text = e.ToString()

        End Try



    End Sub
End Class
